import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class CreateTable {
    private static String driverClass = "org.apache.hive.jdbc.HiveDriver";
    public static void main(String[] args) throws SQLException {

        try {
            Class.forName(driverClass);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Connection connection = DriverManager.getConnection("jdbc:hive2://niit-china:10000/default","root","singh321");
        Statement statement = connection.createStatement();
        String table_name ="BatchB3B4";
        String query1 = "Drop Table "+table_name;
        try {
            statement.execute(query1);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        String query2 = "Create Table "+table_name+" (id int, name string, address string)";
        statement.execute(query2);
        System.out.println("Table has been created successfully");
        statement.close();
        connection.close();

    }
}
